package com.example.wangshuo.zyfypt_205ws.activity;


import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.wangshuo.zyfypt_205ws.R;
import com.example.wangshuo.zyfypt_205ws.iface.RegisterListener;
import com.example.wangshuo.zyfypt_205ws.model.RegisterModel;

public class RegisterActivity extends AppCompatActivity implements View.OnClickListener, RegisterListener {
    private EditText user,password,tel,name,sex;
    private Button register,returnlogin;
    private RegisterModel registerModel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_register);
        user=(EditText)findViewById(R.id.editText6);
        password=(EditText)findViewById(R.id.editText7);
        tel=(EditText)findViewById(R.id.editText8);
        name=(EditText)findViewById(R.id.editText9);
        sex=(EditText)findViewById(R.id.editText10);
        register=(Button)findViewById(R.id.button6);
        returnlogin=(Button)findViewById(R.id.button7);

        register.setOnClickListener(this);
        returnlogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.button6:
                registerModel=new RegisterModel();
                registerModel.getregtList(user.getText().toString(),password.getText().toString(),tel.getText().toString(), this);
                break;
            case R.id.button7:
                startActivity(new Intent(getApplication(),LoginActivity.class));
                RegisterActivity.this.finish();
                break;
        }
    }
    public void onResponse(String str) {
        if(str.equals("1")){
            Intent intent1=new Intent(RegisterActivity.this,LoginActivity.class);
            startActivity(intent1);
        }else{
            Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
        }
    }

    @Override
    public void onFail(String msg) {

    }
}
